﻿using System.Linq;
using System.Web.Mvc;
using Omu.AwesomeDemo.Core.Model;
using Omu.AwesomeDemo.Core.Repository;
using Omu.AwesomeDemo.Infra.Dto;

namespace Omu.AwesomeDemo.WebUI.Controllers
{
    public class AjaxCheckBoxListDemoController : BaseController
    {
        private readonly IRepo<Hobby> hobbyRepo;

        public AjaxCheckBoxListDemoController(IRepo<Hobby> hobbyRepo)
        {
            this.hobbyRepo = hobbyRepo;
        }

        public ActionResult Index()
        {
            return View(new AjaxCheckBoxListDemoInput{ Hobbies = hobbyRepo.GetAll().Take(3).Select(o => o.Id)});
        }

        [HttpPost]
        public ActionResult Index(AjaxCheckBoxListDemoInput input)
        {
            return View(input);
        }
    }
}